package com.project.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.project.bean.EmployeeBean;
import com.project.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

@RestController
@RequestMapping("em")
public class EmployeeController {
    @Autowired
    private IEmployeeService service;

    @RequestMapping("add")
    public String add(EmployeeBean emObj){
        service.add(emObj);
        return "ok";
    }

    @RequestMapping("dimission")
    public String dimission(Integer id){
        service.dimission(id);
        return "ok";
    }

    @RequestMapping("update")
    public String update(Integer id,String job){
        service.update(id, job);
        return "ok";
    }

    @RequestMapping("findByItem")
    public IPage<EmployeeBean> findByItem(Integer pageNO,
                                          String name, LocalDate startDate,LocalDate endDate){
        return service.findByItem(pageNO, name, startDate, endDate);
    }

    @RequestMapping("findById")
    public EmployeeBean findById(Integer id){
        return service.findById(id);
    }
}
